<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
  <title>Zen Mkup tests</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  <script src="assets/jsunittest.js" type="text/javascript"></script>
  
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/prototype/1.6.0.2/prototype.js" type="text/javascript" charset="utf8"></script>
  <script src="../Mkup.js" type="text/javascript"></script>
  <script src="../ZenMkup.js" type="text/javascript"></script>
  
  <link rel="stylesheet" href="assets/unittest.css" type="text/css" />
</head>
<body>

<div id="content">

  <div id="header">
    <h1>JavaScript unit test file</h1>
    <p>
      This file tests <strong>ZenMkup.js</strong>.
    </p>
  </div>

  <!-- Log output (one per Runner, via {testLog: "testlog"} option)-->
  <div id="testlog"></div>
  
  <!-- Put sample/test html here -->
  <div id="sample">
  </div>
</div>

<script type="text/javascript">
// <![CDATA[
	function runZenMkup(zenExpr){
		Mkup.zen($('sample')).write(zenExpr);
	}
	
	new Test.Unit.Runner({
    	
		setup: function() {},
    
    	teardown: function() {
			$('sample').innerHTML = "";
    	},

		
    
    	testPlus: function() { with(this) {
			var items = 30, zen=[];
			items.times(function(){
				zen.push("span");
			});
			zen = zen.join("+");
			runZenMkup(zen);
			assertEqual(items, $('sample').select("span").length);
			info("Zen expression: "+zen);
			info("Creating "+items+" <span> elements inside the target element works.");
    	}},

		testChild:function(){with(this){
			var levels = 30, zen=[], currentNode;
			levels.times(function(){
				zen.push("span");
			});
			zen = zen.join(">");
			runZenMkup(zen);
			currentNode = $('sample');
			levels.times(function(idx){
				var matches = currentNode.select("span");
				assertEqual(levels-idx, matches.length);
				currentNode = matches.first();
			});
			info("Zen expression: "+zen);
		}},
		
		testAttributes:function(){with(this){
			var zen = "div>span[title='test']";
			runZenMkup(zen);
			assertEqual(1, $('sample').select("div>span[title='test']").length);
			info("Zen expression: "+zen);
		}}

		
  }); 
// ]]>
</script>
</body>
</html>